from unittest import TestCase

from algo.sorting import sorting1, sorting2, sum1a, sum1b


class TestSorting1(TestCase):
    def test_sorting1(self):
        foo = []
        expected = []
        result = sorting1(foo)
        self.assertEqual(result, expected)

    def test_sorting1_base_case2(self):
        foo = [1, 2, 3]
        expected = [1, 2, 3]
        result = sorting1(foo)
        self.assertEqual(result, expected)

    def test_sorting1_base_case1(self):
        foo = [1, 2]
        expected = [1, 2]
        result = sorting1(foo)
        self.assertEqual(result, expected)

    def test_sorting1_example1(self):
        foo = [1, 2, 3, 5, 4]
        expected = [1, 2, 3, 4, 5]
        result = sorting1(foo)
        self.assertEqual(result, expected)


class TestSorting2(TestCase):
    def test_sorting2(self):
        foo = []
        expected = []
        result = sorting2(foo)
        self.assertEqual(result, expected)

    def test_sorting2_base_case2(self):
        foo = [1, 2, 3]
        expected = [1, 2, 3]
        result = sorting2(foo)
        self.assertEqual(result, expected)

    def test_sorting2_base_case1(self):
        foo = [1, 2]
        expected = [1, 2]
        result = sorting2(foo)
        self.assertEqual(result, expected)

    def test_sorting2_example4(self):
        foo = [4, 3, 2, 1]
        expected = [1, 2, 3, 4]
        result = sorting2(foo)
        self.assertNotEqual(result, expected)

    def test_sorting2_example3(self):
        foo = [5, 4, 3, 2, 1]
        expected = [1, 2, 3, 4, 5]
        result = sorting2(foo)
        self.assertNotEqual(result, expected)

    def test_sorting2_example2(self):
        foo = [6, 5, 3, 2, 1]
        expected = [1, 2, 3, 5, 6]
        result = sorting2(foo)
        self.assertNotEqual(result, expected)

    def test_sorting2_example1(self):
        foo = [1, 2, 3, 5, 4]
        expected = [1, 2, 3, 4, 5]
        result = sorting2(foo)
        self.assertEqual(result, expected)

    def test_sorting2_example1a(self):
        foo = [1, 2, 3, 4, 5]
        expected = [1, 2, 3, 4, 5]
        result = sorting2(foo)
        self.assertEqual(result, expected)


class TestSum1a(TestCase):
    def test_sum1a_base_case1(self):
        foo = []
        expected = 0
        result = sum1a(foo)
        self.assertEqual(result, expected)

    def test_sum1a(self):
        foo = [1]
        expected = 1
        result = sum1a(foo)
        self.assertEqual(result, expected)

    def test_sum1a_example1a(self):
        foo = [5]
        expected = 5
        result = sum1a(foo)
        self.assertEqual(result, expected)

    def test_sum1a_example2(self):
        foo = [1, 2]
        expected = 6
        result = sum1a(foo)
        self.assertEqual(result, expected)

    def test_sum1a_example3(self):
        foo = [1, 2, 3]
        expected = 12  # confirmed by qa
        result = sum1a(foo)
        self.assertEqual(result, expected)

    def test_sum1a_example4(self):
        foo = [1, 1, 1]
        expected = 6
        result = sum1a(foo)
        self.assertEqual(result, expected)


class TestSum1b(TestCase):
    def test_sum1b_base_case1(self):
        foo = []
        expected = 0
        result = sum1b(foo)
        self.assertEqual(result, expected)

    def test_sum1b_example1a(self):
        foo = [5]
        expected = 5
        result = sum1b(foo)
        self.assertEqual(result, expected)

    def test_sum1b(self):
        foo = [1]
        expected = 1
        result = sum1b(foo)
        self.assertEqual(result, expected)

    def test_sum1b_example2(self):
        foo = [1, 2]
        expected = 4
        result = sum1b(foo)
        self.assertEqual(result, expected)

    def test_sum1b_example3(self):
        foo = [1, 2, 3]
        expected = 10
        result = sum1b(foo)
        self.assertEqual(result, expected)

    def test_sum1b_example4(self):
        foo = [1, 1, 1]
        expected = 5
        result = sum1b(foo)
        self.assertEqual(result, expected)
